﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using PeekService;

namespace PeekWebApp.handler
{
    /// <summary>
    /// MessageHandler 的摘要说明
    /// </summary>
    public class MessageHandler : IHttpHandler
    {

        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            string username = context.Request["username"];
            string email = context.Request["email"];
            string msg = context.Request["msg"];
            UserMessage um = new UserMessage();
            um.Code = Guid.NewGuid().ToString();
            um.CreateID = "";
            um.CreateTime = DateTime.Now;
            um.Email = email;
            um.Name = username;
            um.Message = msg;
            um.Remark = "";
            um.Sort = new ExtendService().GetSort("UserMessage");
            um.State = 0;
            if (new UserMessageService().Add(um))
            {
                context.Response.Write("1");
            }
            else {
                context.Response.Write("0");
            }

        }

        public bool IsReusable
        {
            get
            {
                return false;
            }
        }
    }
}